<!DOCTYPE html>
<html>
<head>
    <title>Test Game</title>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>

    <link href="/css/style.css" rel="stylesheet">
    <link href="/javascripts/ionic-v1.0.0/css/ionic.min.css" rel="stylesheet">
    <script src="/javascripts/jquery-1.11.1.min.js"></script>

    <script src="/javascripts/ionic-v1.0.0/js/ionic.bundle.min.js"></script>
    <script src="/javascripts/moment-with-locales.min.js"></script>
    <script src="/socket.io-1.2.0.js"></script>

    <!-- main.min.js 对应文件 app.js directives.js controller.js services.js filters.js -->
    <script src="/main/main.min.js?t=20150617"></script>
    <!--<script src="/main/app.js"></script>
    <script src="/main/directives.js"></script>
    <script src="/main/controllers.js"></script>
    <script src="/main/services.js"></script>
    <script src="/main/filters.js"></script>-->


    <!-- command.min.js 对应文件  command.js  -->
    <!--
    <script src="/command.js"></script>
    -->
    <script src="/command.min.js"></script>

    <script type="text/javascript">
        //设置时间本地化
        moment.locale('zh-cn');

        <% if(user){ %>

            //web socket的端口为 http服务端口 + 1
            var socket = io.connect('ws://' + location.hostname + ':' + (Number(location.port)+1), { 'reconnect': false});

            //先连接3001端口,如果失败则连接3000端口-用于测试
            setInterval(function(){
                socket.emit(Command.PING, {
                    userId: '<%=user._id%>'
                });
            }, 5000);

            socket.on('disconnect', function(){
                alert('呃，掉线了~');
                window.location = window.location.href.split('#')[0];
            });

            //向服务器发送消息，表示客户端已经准备好了
            socket.emit(Command.CLIENT_READY, {
                userId: '<%=user._id%>'
            });

            USERINFO = {
                userId: '<%=user._id%>',
                name : '<%=user.name%>',
                profession : '<%=user.profession%>'
            };

            SETTINGS = {
                minNum : <%=settings.minNum%>,
                maxNum : <%=settings.maxNum%>
            };
        <%} %>
    </script>
    <link rel="stylesheet" href="/css/reset.css"/>
</head>
<body ng-app="starter">
    <div class="box">
        <div class="box-bd">
        <% if(user){ %>
            <div id="sitemsg" ng-class="siteMsgCls" ng-bind="siteMessage">
            </div>
            <ion-nav-bar class="bar-stable">
                <ion-nav-back-button>
                </ion-nav-back-button>
            </ion-nav-bar>
            <ion-nav-view></ion-nav-view>
        <% }else { %>
            <div class="list card">
                <div class="item item-text-wrap">错误的SID,未登陆成功!</div>
            </div>
        <% } %>
        </div>
    </div>

    <audio loop="" src="/resources/bgm1_loop.mp3" id="media" autoplay="" preload=""></audio>

    <script>
        var u = navigator.userAgent;
        if(u.indexOf('iPhone') > -1) {//苹果手机
            $(document).one('touchstart', function() {
                document.getElementById('media').load();
            })
        }
    </script>
</body>
</html>
